package com.yonyong.tao.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;

/**
 * @Author yonyong
 * @Description //配置swagger
 * @Date 2020/3/5 13:58
 * @Param
 * @return
 **/
@Configuration
public class Swagger2Config {
    @Bean
    public Docket createRestApi() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.yonyong.tao.controller"))
                .paths(PathSelectors.any())
                .build();
    }

    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                .title("API 文档")
                .description("接口文档")
                .termsOfServiceUrl("http://www.yonyong.top/")
                .version("1.0.0")
                .description("本文档用于yonyong测试可视化接口文档。阅读本文档时，如果有接口描述，请先阅读接口的接口描述，谢谢配合！")
                .contact("yonyong")
                .build();
    }
}